import requests
import time
import sys

headers = {
    "User-Agent": "MiFit/4.6.0 (iPhone; iOS 14.0.1; Scale/2.00)",
    "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
}


def main():
    getTime = time.strftime("%Y%m%d", time.localtime())
    url = "http://serunozlt.dxmdh.com/"
    try:
        resp = requests.post(url, headers=headers)
        # print(resp.json()['imageUrl'])
        img_resp = requests.get(resp.json()['imageUrl'], headers=headers)
        with open(getTime + '.png', mode="wb") as f:
            f.write(img_resp.content)  # 图片内容写入文件
        print("over")
    except NameError:
        print("请求失败")
        sys.exit()


if __name__ == '__main__':
    main()
